package com.yjyw.tiexie.util.update;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.yjyw.tiexie.R;

import java.util.List;

/**
 * Created on 2019/8/12.
 *
 * @author ${AUTHOR}
 * TODO:
 */
public class VersionUpdateAdapter extends RecyclerView.Adapter<VersionUpdateAdapter.ViewHoider> {
    private Context context;
    private List<String> updateContent;

    public VersionUpdateAdapter(Context context, List<String> updateContent) {
        this.context = context;
        this.updateContent = updateContent;
    }

    @Override
    public ViewHoider onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_version_update, parent, false);
        return new ViewHoider(view);
    }

    @Override
    public void onBindViewHolder(ViewHoider holder, int position) {
        holder.tv.setText(updateContent.get(position));

    }

    @Override
    public int getItemCount() {
        return updateContent == null ? 0 : updateContent.size();
    }

    class ViewHoider extends RecyclerView.ViewHolder {
        private TextView tv;

        public ViewHoider(View itemView) {
            super(itemView);
            tv = (TextView) itemView.findViewById(R.id.tv);
        }
    }
}
